import React, { useState } from 'react';
import { Switch, View, Text } from 'react-native';

const SettingsSwitch = ({ label, defaultValue, onChange }) => {
  const [isEnabled, setIsEnabled] = useState(defaultValue);

  return (
    <View style={styles.container}>
      <Text>{label}</Text>
      <Switch
        trackColor={{ false: "#767577", true: "#81b0ff" }}
        thumbColor={isEnabled ? "#f5dd4b" : "#f4f3f4"}
        ios_backgroundColor="#3e3e3e"
        onValueChange={(value) => {
          setIsEnabled(value);
          onChange(value);
        }}
        value={isEnabled}
      />
    </View>
  );
};

export default SettingsSwitch;